package com.itheima.edu.info.manager.controller;

import com.itheima.edu.info.manager.domain.Student;
import com.itheima.edu.info.manager.service.StudentService;


import java.util.Scanner;

public class StudentController extends BaseStudentController{
    @Override
    public void addStudent() {
        Student student = new Student();
        String id;
        while (true) {
            System.out.println("请输入学号id：");
            id = sc.next();
            boolean ss = studentService.affirm(id);
            if (ss) {
                System.out.println("学号重复，请重新输入：");
            } else {
                break;
            }
        }
        System.out.println("请输入名字：");
        String name = sc.next();
        System.out.println("请输入年龄：");
        String age = sc.next();
        System.out.println("请输入生日（格式：****—**—**）：");
        String birthday = sc.next();
        student.setID(id);
        student.setName(name);
        student.setAge(age);
        student.setBirthday(birthday);
        boolean result = studentService.addStudent(student);
        if (result) {
            System.out.println("添加成功");
        } else {
            System.out.println("添加失败");
        }
    }
}
